package org.beiming;

public enum CashStrategy {
    NORMAL("正常收费") {
        @Override
        public CashSuper createStrategy() {
            return new CashNormal();
        }
    },
    RETURN("满300减100") {
        @Override
        public CashSuper createStrategy() {
            return new CashReturn(300, 100);
        }
    },
    REBATE("打8折") {
        @Override
        public CashSuper createStrategy() {
            return new CashRebate(0.8);
        }
    };

    private final String label;

    CashStrategy(String label) {
        this.label = label;
    }

    public static CashStrategy valueOfLabel(String label) {
        for (CashStrategy strategy : values()) {
            if (strategy.label.equals(label)) {
                return strategy;
            }
        }
        throw new IllegalArgumentException("Unsupported strategy label: " + label);
    }

    public abstract CashSuper createStrategy();
}
